package com.colin.app.fragment.demo;


import android.os.Bundle;
import android.view.View;

import com.colin.app.R;
import com.colin.app.app.AppActivity;
import com.colin.app.app.AppFragment;


public class DemoFragment extends AppFragment implements DemoContract.DemoView, View.OnClickListener {
    private DemoContract.DemoPresenter mDemoPresenter = null;
    private static final String FRAGMENT_ID = "fragment_id";
    private int fragment_id;
    public static DemoFragment newInstance(AppActivity mAppActivity, int fragment_id) {
        activity = mAppActivity;
        DemoFragment fragment = new DemoFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(FRAGMENT_ID, fragment_id);
        fragment.setArguments(bundle);
        return fragment;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        fragment_id = bundle.getInt(FRAGMENT_ID);
    }

    @Override
    public void onDestroyView() {
        if (null!=mDemoPresenter){
            mDemoPresenter.destroy();
            mDemoPresenter = null;
        }
        super.onDestroyView();
    }

    @Override
    public void initPresenter() {
        mDemoPresenter = new DemoPresenterImpl((AppActivity) activity,this);
    }

    @Override
    public int initViewLayoutID() {
        return R.layout.fragment_demo;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initListener() {
        this.getView().findViewById(R.id.button_demo_coordinator).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button_demo_coordinator:
                mDemoPresenter.toCoordinatorTabLayoutActivity();
                break;
        }
    }
}
